<!doctype html>
<html>
  
  <head>
    <meta charset="utf-8">
    <title>登录-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
  </head>
  
  <body>
    <!--------头部开始-------------->
    <include file="Public/header" />
    <!--------头部结束-------------->
    <link rel="stylesheet" href="/Template/pc/kty/Static/css/vip_login.css"/>
    <div class="loginbg">
        <div class="save1200">
            <div class="loginjm ftr">
                <h2 class="ftl">会员登录<span><a href="">立即注册</a></span></h2>
                <form action="{:U('Home/User/do_login')}" class="ftl login">
                    <label for="user" class="ftl" style="margin-top: 30px;margin-left: 33px;">手机号/用户名</label>
                    <input class="ftl" type="text" id="username"/>
                    <label class="ftl" for="user" style="margin-left: 33px;">密码</label>
                    <input class="ftl" type="password" id="password"/>
                    <input type="checkbox" class="ftl" id="check"/> <label class="ftl"  for="check"  style="margin-left: 8px;margin-top: -2.6px;">记住用户名密码</label>
                    <span class="ftr"><a href="">忘记密码</a></span>
                    <button type="button" onclick="checkSubmit()" class="ftl btn">登录</button>
                </form>
            </div>
        </div>
    </div>

    <div class="footer3">
        <div class="save1200">
            <div class="ftspan1">
                <span>联系电话：12345678912</span>
                <span> 联系QQ：12345678912</span>
                <span> 传真：12345678912</span>
                <span style="margin-right: 0px;margin-left: 14px;"> 电子邮箱：12345678912@163.com</span>
            </div>
            <div class="ftspan2">
                <span>公司地址：上海 上海金山 上海市金山区枫泾镇环东一路65弄4号3258室</span>
            </div>
            <div class="ftspan3">
                <span>沪ICP备15037721号 | 食品流通许可证SP3101051510004275 | 上海市长宁区天山西路789号中山国际广场B座2层 | © Copyright 2015 技术支持：东方硅谷</span>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    function verify(){
       $('#verify_code_img').attr('src','/index.php?m=Home&c=User&a=verify&r='+Math.random());
    }
    
    function checkSubmit()
    {
        var username = $.trim($('#username').val());
        var password = $.trim($('#password').val());
        var referurl = $('#referurl').val();
        if(username == ''){
            showErrorMsg('用户名不能为空!');
            return false;
        }
        if(!checkMobile(username) && !checkEmail(username)){
            showErrorMsg('账号格式不匹配!');
            return false;
        }
        if(password == ''){
            showErrorMsg('密码不能为空!');
            return false;
        }
        
        $.ajax({
            type : 'post',
            url : '/index.php?m=Home&c=User&a=do_login&t='+Math.random(),
            data : {username:username,password:password,referurl:referurl},
            dataType : 'json',
            success : function(res){
                if(res.status == 1){
                    window.location.href = res.url;
                }else{
                    showErrorMsg(res.msg);
                    verify();
                }
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                showErrorMsg('网络失败，请刷新页面后重试');
            }
        })
        
    }
    
    function checkMobile(tel) {
        var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
        if (reg.test(tel)) {
            return true;
        }else{
            return false;
        };
    }
    
    function checkEmail(str){
        var reg = /^[a-z0-9]([a-z0-9\\.]*[-_]{0,4}?[a-z0-9-_\\.]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+([\.][\w_-]+){1,5}$/i;
        if(reg.test(str)){
            return true;
        }else{
            return false;
        }
    }
    
    function showErrorMsg(msg){
        alert(msg);
    }
</script>